﻿//判断手机号码
function isPhone(obj,value) {
    	reg = /^1\d{10}$/;
	 if(!reg.test(value)){       
		 swal({
    			title:"请输入正确的手机号码",
    			text: "1秒后自动关闭。", 
    			timer: 1000, 
			    showConfirmButton: false
    		});
		 $("#"+obj).val('');
     }
}
//判断电子邮箱
function isEmail(obj,value) {
	reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	 if(!reg.test(value)){       
		 swal({
    			title:"请输入正确的邮箱地址",
    			text: "1秒后自动关闭。", 
    			timer: 1000, 
			    showConfirmButton: false
    		});
		 $("#"+obj).val('');
         }
	}
  //判断身份证号码
function isIdCard(obj,value) {
	reg =  /^\d{15}(\d{2}[A-Za-z0-9])?$/; 
	 if(!reg.test(value)){       
		 swal({
    			title:"请输入正确的身份证号",
    			text: "1秒后自动关闭。", 
    			timer: 1000, 
			    showConfirmButton: false
    		});
		 $("#"+obj).val('');
     }
}
//只能输入正整数
function isInteger(obj,value) {
	reg =/^\+?[1-9][0-9]*$/;
	if(!reg.test(value)){       
		 swal({
   			title:"请输入正确的数字",
   			text: "1秒后自动关闭。", 
   			timer: 1000, 
			    showConfirmButton: false
   		});
		 $("#"+obj).val('');
    }
}
//整数或者小数
function isIntDec(obj,value) {
	reg =  /^[0-9]+\.{0,1}[0-9]{0,2}$/; 
	 if(!reg.test(value)){       
		 swal({
    			title:"请输入正确的数字",
    			text: "1秒后自动关闭。", 
    			timer: 1000, 
			    showConfirmButton: false
    		});
		 $("#"+obj).val('');
     }
}
//网址
function isUrl(obj,value) {
	reg = /^((https|http|ftp|rtsp|mms){0,1}(:\/\/){0,1})www\.(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
	 if(!reg.test(value)){       
		 swal({
    			title:"请输入正确的网址",
    			text: "1秒后自动关闭。", 
    			timer: 1000, 
			    showConfirmButton: false
    		});
		 $("#"+obj).val('');
     }
}


function CleanPastedHTML(input) {
  // 1. remove line breaks / Mso classes
  var stringStripper = /(\n|\r| class=(")?Mso[a-zA-Z]+(")?)/g;
  var output = input.replace(stringStripper, ' ');
  // 2. strip Word generated HTML comments
  var commentSripper = new RegExp('<!--(.*?)-->','g');
  var output = output.replace(commentSripper, '');
  var tagStripper = new RegExp('<(/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>','gi');
  // 3. remove tags leave content if any
  output = output.replace(tagStripper, '');
  // 4. Remove everything in between and including tags '<style(.)style(.)>'
  var badTags = ['style', 'script','applet','embed','noframes','noscript'];
 
  for (var i=0; i< badTags.length; i++) {
    tagStripper = new RegExp('<'+badTags[i]+'.*?'+badTags[i]+'(.*?)>', 'gi');
    output = output.replace(tagStripper, '');
  }
  // 5. remove attributes ' style="..."'
  var badAttributes = ['style', 'start'];
  for (var i=0; i< badAttributes.length; i++) {
    var attributeStripper = new RegExp(' ' + badAttributes[i] + '="(.*?)"','gi');
    output = output.replace(attributeStripper, '');
  }
  return output;
}